fix(auth): speed up sign-out and show pending state on logout#378
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Improves the perceived and actual speed of user sign-out by reducing sequential network round-trips in the Ory sign-out flow and adding a visible pending state to the sidebar “Log out” menu item while the logout action is in progress.
Changes:
- Parallelize Ory Hydra (OAuth) and Kratos (identity) revocations during sign-out via
Promise.all. - Parallelize Hydra consent + login session revocations.
- Add a transition-driven pending UI for the sidebar logout menu item (disabled state + spinner/label).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/features/dashboard/sidebar/menu.tsx | Adds pending/disabled UI state for logout and keeps the dropdown open while logout is in progress. |
| src/core/server/auth/ory/signout-flow.ts | Runs Hydra OAuth revocation and Kratos session revocation concurrently to reduce sign-out latency. |
| src/core/server/auth/ory/oauth-session.ts | Runs Hydra consent and login session revocations concurrently to reduce sign-out latency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Server actions POST to the current page URL, so logout silently blocked on the full Ory sign-out flow with no feedback. Run the independent Hydra and Kratos revocations concurrently (~3 sequential round-trips down to the slowest one) and wrap the logout action in useTransition with a visible "Logging out..." state.
ac531d4 to
e37639d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b413c3bce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // not awaited on purpose: the action redirects (throws NEXT_REDIRECT), | ||
| // and awaiting it inside the transition surfaces noisy aborted-action | ||
| // errors; the transition still tracks the resulting navigation | ||
| void signOutAction() |
There was a problem hiding this comment.
Keep logout pending until the server action settles
When logout takes more than a moment, this void call makes the transition callback return immediately, so this component’s isLoggingOut can flip back to false before signOutAction() finishes and before the redirect arrives. That defeats the new fullscreen pending overlay and can also re-enable the menu item during the slow sign-out path this change is trying to cover; use an explicit local loggingOut state or have the transition action await/return the server-action promise while handling the redirect noise separately.
Useful? React with 👍 / 👎.
Why
Clicking "Log out" appeared to do nothing for several seconds: server actions POST to the current page URL, so the browser sat waiting on a request to e.g.
/dashboard/<team>/sandboxes/monitoring?...whilecompleteOrySignOutran 4 sequential network round-trips (Auth.js sign-out, Hydra consent + login revocation, Kratos session deletion) before returning the redirect — with no pending UI.What
completeOrySignOut, and the two Hydra calls (consent + login) concurrently as well — ~3 sequential round-trips collapse to the slowest one; all helpers already log-and-swallow errors and Kratos retries 429 contention.useTransitioncallback (void signOutAction(), not awaited — the action redirects via NEXT_REDIRECT and awaiting it surfaces noisy aborted-action errors).document.bodyso the sidebar'sfixed z-20stacking context can't trap it under the sticky dashboard header (z-50).